<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

class FirmBrand extends Model
{
	use HasDateTimeFormatter;


    protected $fillable = [
        'firm_id',
        'name',
        'firm_profession_id',
        'brand_cradle_id',
        'brand_location_id',
        'certificate',
        'user_id',
        'consult_time',
        'audit_status',
        'is_warn'
    ];

    protected $attributes = [
        'certificate' => '',
        'audit_status' => 1,
        'consult_time' => 0
    ];

    protected $casts = [
        'certificate' => 'string',
    ];

    public function firm()
    {
        return $this->belongsTo(Firm::class,'firm_id');
    }

    public function profession()
    {
        return $this->belongsTo(FirmProfession::class,'firm_profession_id');
    }

    public function cradle()
    {
        return $this->belongsTo(BrandCradle::class,'brand_cradle_id');
    }


    public function location()
    {
        return $this->belongsTo(BrandLocation::class,'brand_location_id');
    }


    public function profile()
    {
        return $this->hasOne(FirmBrandProfile::class,'brand_id');
    }


    public function collect()
    {
        return $this->hasMany(UserCollectBrand::class,'brand_id');
    }

    public function like()
    {
        return $this->hasMany(UserLikeBrand::class,'brand_id');
    }

    public function follow()
    {
        return $this->belongsTo(UserFollow::class,'user_id','friend_id');
    }

    public function interested()
    {
        return $this->hasMany(BrandNotInterested::class,'brand_id');
    }

    public function gift()
    {
        return $this->morphMany(Gift::class, 'giftable');
    }
}
